package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IStaffMapper;
import com.project.service.IStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl implements IStaffService{
    private final int PAGESIZE = 5;
    @Autowired
    private IStaffMapper mapper;

    @Override
    public void addEmployee(EmployeeBean employee) {
        mapper.addEmployee(employee);
    }

    @Override
    public void UpdateStatus(int empID, String status) {
        mapper.UpdateStatus(empID, status);
    }

    @Override
    public void updateInfo(int empID, String phone, int salary) {
        mapper.updateInfo(empID, phone, salary);
    }

    @Override
    public EmployeeBean findByID(int empID) {
        return mapper.findByID(empID);
    }

    @Override
    public List<EmployeeBean> findStaff(String name, String Specialty,String status) {
        return mapper.findStaff(name, Specialty,status);
    }

    @Override
    public PageInfo<EmployeeBean> findByItem(int pageNo, String name, String specialty, String state, String order) {
        PageHelper.startPage(pageNo,PAGESIZE);
        PageInfo<EmployeeBean> info = PageInfo.of(mapper.findByItem(name, specialty, state, order));
        return info;
    }
}
